package com.net.xpay.common.manager.impl;

import com.google.common.base.Preconditions;
import com.net.common.dao.BasicMapper;
import com.net.xpay.common.dao.SafePayOrderReceiptMapper;
import com.net.xpay.common.domain.SafePayOrderReceipt;
import com.net.xpay.common.manager.SafePayOrderReceiptManager;
import com.net.common.manager.AbstractManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


@Component
public class SafePayOrderReceiptManagerImpl extends AbstractManager<SafePayOrderReceipt> implements SafePayOrderReceiptManager{

    @Autowired
    private SafePayOrderReceiptMapper mapper;


    @Override
    protected BasicMapper<Long, SafePayOrderReceipt> getMapper() {
        return mapper;
    }

    @Override
    public SafePayOrderReceipt findBySafePayOrderId(Long userId, Long safePayOrderId) {
        Preconditions.checkArgument(userId != null && safePayOrderId != null);
        SafePayOrderReceipt condition = new SafePayOrderReceipt();
        condition.setUserId(userId);
        condition.setSafePayOrderId(safePayOrderId);
        return getByCondition(condition);
    }

    @Override
    public List<Long> listWaitQuery(int limit) {
        List<Long> ids = mapper.listWaitQuery(limit);
        return ids != null ? ids : new ArrayList<>();
    }
}
